package com.mdd.apiinterface.controller;

import com.mdd.apiinterface.generator.domain.Joke;
import com.mdd.apiinterface.generator.mapper.JokeMapper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * @author Mdd
 * @Github <a href="https://github.com/mdd123cc"/>
 * @Gitee <a href="https://gitee.com/mdd115192"/>
 *
 */
@RestController
@RequestMapping("/joke")
public class jokeController {

    @Resource
    private JokeMapper jokeMapper;

    /**
     * 随机获取一个笑话
     * @return
     */
    @PostMapping("/random")
    public String getUserNameByGet(){
        Joke randomJoke = jokeMapper.getRandomJoke();
        if (randomJoke == null) {
            throw new RuntimeException("操作失败");
        }
        return randomJoke.getContext();
    }
}
